Object.defineProperty(exports, "__esModule", { value: !0 }),
  (exports.default = void 0);
var o = require("../../@babel/runtime/helpers/classCallCheck"),
  t = require("../../@babel/runtime/helpers/createClass"),
  e = require("../../@babel/runtime/helpers/possibleConstructorReturn"),
  i = require("../../@babel/runtime/helpers/getPrototypeOf"),
  a = require("../../@babel/runtime/helpers/inherits"),
  n = s(require("./BaseLocationProvider.js")),
  r = s(require("./AoaLocationProvider")),
  c = s(require("./OutdoorLocationProvider"));
function s(o) {
  return o && o.__esModule ? o : { default: o };
}
var u = null;
exports.default = (function (n) {
  function s() {
    var t, a, n, r;
    return (
      o(this, s),
      (a = this),
      (n = i((n = s))),
      ((t = e(
        a,
        (function () {
          if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
          if (Reflect.construct.sham) return !1;
          if ("function" == typeof Proxy) return !0;
          try {
            return !Boolean.prototype.valueOf.call(
              Reflect.construct(Boolean, [], function () {}),
            );
          } catch (o) {
            return !1;
          }
        })()
          ? Reflect.construct(n, r || [], i(a).constructor)
          : n.apply(a, r),
      )).provideType = "integration"),
      (t.locationChangeCallback = []),
      (t.status = "ready"),
      (t.lastestLocation = null),
      (t.aoaStatus = !0),
      (t.isInit = !1),
      t
    );
  }
  return (
    a(s, n),
    t(
      s,
      [
        {
          key: "init",
          value: function () {
            var o = this;
            (this.aoaLocationProvider = new r.default()),
              this.aoaLocationProvider.init(),
              (this.aoaLocationChangeHandle = function (t) {
                (o.lastestAoaLocTime = new Date().getTime()),
                  (o.aoaStatus = !0),
                  o.locationChangeCallback.forEach(function (o) {
                    o && o(t);
                  }),
                  o.emit("locationChange", t);
              }),
              this.aoaLocationProvider.onLocationChange(
                this.aoaLocationChangeHandle,
              ),
              (this.outdoorLocationProvider = new c.default()),
              (this.outdoorLocationChangeHandle = function (t) {
                (o.lastestOudoorLocTime = new Date().getTime()),
                  o.aoaStatus ||
                    (o.locationChangeCallback.forEach(function (o) {
                      o && o(t);
                    }),
                    o.emit("locationChange", t));
              }),
              this.outdoorLocationProvider.onLocationChange(
                this.outdoorLocationChangeHandle,
              ),
              (this.isInit = !0);
          },
        },
        {
          key: "onAppShow",
          value: function () {
            this.aoaLocationProvider &&
              this.aoaLocationProvider.locationApp &&
              this.aoaLocationProvider.locationApp.onAppShow();
          },
        },
        {
          key: "onAppHide",
          value: function () {
            this.aoaLocationProvider &&
              this.aoaLocationProvider.locationApp &&
              this.aoaLocationProvider.locationApp.onAppHide();
          },
        },
        {
          key: "startSceneChecker",
          value: function () {
            var o = this;
            this.sceneCheckTimer &&
              (clearInterval(this.sceneCheckTimer),
              (this.sceneCheckTimer = -1)),
              (this.sceneCheckTimer = setInterval(function () {
                var t = new Date().getTime();
                o.lastestAoaLocTime
                  ? (console.log(
                      "====sceneCheckTimer:",
                      t - o.lastestAoaLocTime,
                    ),
                    t - o.lastestAoaLocTime > 12e3
                      ? (console.log("====切换到室外场景"), (o.aoaStatus = !1))
                      : (o.aoaStatus = !0))
                  : (o.aoaStatus = !1);
              }, 5e3));
          },
        },
        {
          key: "startLocation",
          value: function () {
            var o =
              arguments.length > 0 && void 0 !== arguments[0]
                ? arguments[0]
                : {};
            this.isInit || this.init(),
              "running" !== this.status
                ? (this.aoaLocationProvider &&
                    this.aoaLocationProvider.startLocation(o),
                  this.outdoorLocationProvider &&
                    this.outdoorLocationProvider.startLocation(o),
                  this.startSceneChecker())
                : console.log("===一体化定位已启动");
          },
        },
        {
          key: "onLocationChange",
          value: function (o) {
            this.locationChangeCallback.push(o);
          },
        },
        {
          key: "stopLocation",
          value: function () {
            this.aoaLocationProvider && this.aoaLocationProvider.stopLocation(),
              this.outdoorLocationProvider &&
                this.outdoorLocationProvider.stopLocation(),
              clearInterval(this.sceneCheckTimer);
          },
        },
        {
          key: "dispose",
          value: function () {
            this.aoaLocationProvider && this.aoaLocationProvider.dispose(),
              this.outdoorLocationProvider &&
                this.outdoorLocationProvider.dispose(),
              this.locationApp.destroy();
          },
        },
      ],
      [
        {
          key: "getInstance",
          value: function () {
            return null === u && (u = new this()), u;
          },
        },
      ],
    )
  );
})(n.default);
